import request from 'src/axios'

/**
 * @description 分页查询字典项
 * @param { Object } params 查询参数
 * @returns Promise
 */
export const pageDict = (params: object) => {
  return request.get('/system/dict/page', { params })
}

/**
 * @description 查询启用字典项
 * @param { Object } params 查询参数
 * @returns Promise
 */
export const listDict = (params?: object) => {
  return request.get('/system/dict/list', { params })
}

/**
 * @description 查看字典项
 * @param { String } id 主键
 * @returns Promise
 */
export const viewDict = (id: string) => {
  return request.get('/system/dict', { params: { id } })
}

/**
 * @description 新增字典项
 * @param { Object } data 新增数据
 * @returns Promise
 */
export const saveDict = (data: object) => {
  return request.post('/system/dict', data)
}

/**
 * @description 修改字典项
 * @param { Object } data 修改数据
 * @returns Promise
 */
export const updateDict = (data: object) => {
  return request.put('/system/dict', data)
}

/**
 * @description 删除字典项
 * @param { Array<string> } ids 主键数组
 * @returns Promise
 */
export const deleteDict = (ids: Array<string>) => {
  return request.delete('/system/dict', { data: ids })
}

/**
 * @description 启用字典
 * @param { String } id 主键
 * @returns Promise
 */
export const enableDict = (id: string) => {
  return request.put('/system/dict/enable', { id })
}

/**
 * @description 禁用字典
 * @param { String } id 主键
 * @returns Promise
 */
export const disableDict = (id: string) => {
  return request.put('/system/dict/disable', { id })
}
